package com.yoki.cloud.common.protocol.radius.msg.packet.acct.resp;


import com.yoki.cloud.common.protocol.radius.attribute.attr.check.ProxyStateAttr;
import com.yoki.cloud.common.protocol.radius.attribute.attr.check.VendorSpecificAttr;
import com.yoki.cloud.common.protocol.radius.msg.packet.RadiusMsg;
import com.yoki.cloud.common.protocol.radius.msg.packet.RespRadiusMsg;

/**
 * @author Sky$
 * @Description: TODO
 * @date 2018/1/12$ 9:33$
 */
public class AccountingResponseMsg extends RespRadiusMsg {

    public static final int PACKET_CODE = 5;

    public AccountingResponseMsg(String secret, RadiusMsg reqMsg) {
        super(secret, reqMsg);
        code = getPacketCode() ;
    }

    @Override
    public int getPacketCode() {
        return PACKET_CODE;
    }

    @Override
    protected boolean typeLegal(int type , boolean print) {
        if ((type != ProxyStateAttr.ATTR_TYPE) && (type == VendorSpecificAttr.ATTR_TYPE)) {
            if(print) {
                System.out.println("Data can not be converted into this type of attribution , Type is inconsistent !!! " +
                        "Radius Accounting-Response packet required type can not be [ "
                        + ProxyStateAttr.ATTR_TYPE + " , " + VendorSpecificAttr.ATTR_TYPE
                        + " ]");
            }
            return false;
        }
        return true;
    }
}
